package CtrLayer;
import java.util.ArrayList;

import DBLayer.*;
import ModelLayer.Employee;

/**
 *PersonCtr
 *This class handles methods related to employees.
 *31/05/2012
 *@author Bager
 *@version 0.1
 */

public class PersonCtr {
	
	private static PersonCtr instance;
	
	/**
	 * Creates a new personCtr.
	 */
	
	private PersonCtr()
	{
		
	}
	
	/**
	 * Returns a instance of PersonCtr if a PersonCtr already exist, creates a new PersonCtr and returns it if a PersonCtr don't already exist.
	 * @return A instance of PersonCtr. 
	 */
	
	public static PersonCtr getInstance()
	{
		if(instance==null)
        {
            instance = new PersonCtr();
        }
        return instance;
	}

	/**
	 * Finds and returns the employee with a matching login name.
	 * @param login The login of the employee to return. 
	 * @return A employee with matching login.
	 */

	public Employee selectEmployee(String login)
	{
		EmployeeDBIF dbEmployee = new EmployeeDB();
		return dbEmployee.searchEmployeeLoginName(login, false);
	}
	
	/**
	 * Returns all employees in the database.
	 * @return A arrayList with employees in the database.
	 */
	
	public ArrayList<Employee> getAllEmployees() {
		// TODO Auto-generated method stub
		
		EmployeeDBIF dbEmployee = new EmployeeDB();
		System.out.println("ArrayList<Employee> : "+dbEmployee);
		return dbEmployee.getAllEmployees(false);
	}
}
